package com.zhuangjie.order.vo;

import com.zhaungjie.base.utils.PropertiesCopyUtils.PropertiesCopy;
import com.zhuangjie.order.entity.Order;
import com.zhuangjie.order.entity.OrderDetail;
import lombok.Data;

import java.util.List;

@Data
class OrderDishBaseInfo {
    /**
     * 菜品id
     */
    private Long dishId;

    /**
     * 商品名称
     */
    private String name;

    /**
     * 商品图片路径
     */
    private String image;
}
@Data
public class OrderForUserVO extends Order {
    private String shopName;

    private String shopLogo;

    private List<OrderDishBaseInfo> dishList;

    public void setDishList( List<OrderDetail> orderDetailList) {
        if (orderDetailList == null || orderDetailList.isEmpty() ) {
            return;
        }
        // 将orderDetailList转为OrderDishBaseInfo赋值给this.dishList
        this.dishList = PropertiesCopy.type(OrderDetail.class, OrderDishBaseInfo.class)
                .batchProduce(orderDetailList);
    }
}
